home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_oth / m2cmp20 / system.def < prev    next >
Text File  |  1988-11-19  |  5KB  |  162 lines

  1. DEFINITION MODULE System;
  2.  
  3. (* (C) Copyright 1987,1988 Fitted Software Tools. All rights reserved. *)
  4.  
  5. (*
  6.     This module contains definitions that are SYSTEM DEPENDENT.
  7.     This version is for the IBM PC running DOS >= 2.0.
  8. *)
  9.  
  10. FROM SYSTEM IMPORT  WORD, ADDRESS;
  11.  
  12.  
  13. TYPE
  14.     MemoryModel = ( tiny, small, compact, medium, large, huge );
  15.  
  16. VAR
  17.     MemModel    :MemoryModel;   (* mem model used to compile/link this pgm *)
  18.     DOSVersion  :CARDINAL;      (* DOS version * 100 *)
  19.     PSP         :CARDINAL;      (* paragraph pointer to DOS program prefix *)
  20.     MemTop      :CARDINAL;      (* end of memory (paragraph) *)
  21.     HeapBase    :CARDINAL;      (* start of heap (paragraph) *)
  22.     StackSeg    :CARDINAL;      (* stack segment (paragraph) *)
  23.     StackSize   :CARDINAL;      (* initial SP value          *)
  24.     HeapTop     :CARDINAL;      (* end of heap   (paragraph) *)
  25.                                 (* updated by Storage        *)
  26.     Has8087     :BOOLEAN;       (* 8087 math coprocessor present ? *)
  27.  
  28.     AX, BX, CX, DX, SI, DI :CARDINAL;
  29.     BP, DS, ES             :CARDINAL;
  30.     FLAGS                  :BITSET;
  31.  
  32. CONST
  33.     carryFlag   = 0;                (* carry flag IN FLAGS *)
  34.     zeroFlag    = 6;                (* zero flag IN FLAGS *)
  35.  
  36.  
  37. PROCEDURE GetArg( VAR arg: ARRAY OF CHAR; VAR length :CARDINAL );
  38. (*
  39.     returns the next argument in the command line.
  40.  
  41.     1. spaces separate arguments.
  42.     2. / starts a new argument (option).
  43.     3. to override the above, an argument may be quoted (Modula-2
  44.        string).
  45.  
  46.     Ex: COMMAND arg1 'arg 2' /option "command's last arg"
  47. *)
  48.  
  49. PROCEDURE GetEnv( var :ARRAY OF CHAR; VAR val :ARRAY OF CHAR );
  50. (*
  51.     loads val with the value of the environment variable var.
  52.     val will be loaded with the null string if var is not found.
  53. *)
  54.  
  55. PROCEDURE Trap( intno :CARDINAL );
  56. (*
  57.     loads the 8088 registers with the contents of AX..DI
  58.     and then generates the software interrupt specified.
  59.  
  60.     On return from the interrupt, the registers are saved
  61.     in AX..DI. The processor flags are stored in FLAGS.
  62. *)
  63.  
  64. PROCEDURE XTrap( intno :CARDINAL );
  65. (*
  66.     loads the 8088 registers with the contents of AX..ES
  67.     and then generates the software interrupt specified.
  68.  
  69.     On return from the interrupt, the registers are saved
  70.     in AX..ES. The processor flags are stored in FLAGS.
  71. *)
  72.  
  73. PROCEDURE Move( src :ADDRESS; dest :ADDRESS; size :CARDINAL );
  74. (*
  75.     Move size bytes from src to dest.
  76.  
  77.     IF FLAT(src) > FLAT(dest) THEN
  78.         move from low to high address
  79.     ELSE
  80.         move from high to low address
  81.     END
  82. *)
  83.  
  84. PROCEDURE TermProcedure( p :PROC );
  85. (*
  86.     installs a procedure to be executed when the program
  87.     terminates.
  88.  
  89.     Up to 20 termination procedures may be installed.
  90. *)
  91.  
  92. PROCEDURE Terminate( exitStatus :CARDINAL );
  93. (*
  94.     terminates execution, sets the DOS errorlevel to exitStatus
  95. *)
  96.  
  97. PROCEDURE GetVector( IntNum :CARDINAL; VAR ISR :ADDRESS );
  98. (*
  99.     loads in ISR the value of the interrupt vector IntNum
  100. *)
  101.  
  102. PROCEDURE SetVector( IntNum :CARDINAL; ISR :PROC );
  103. (*
  104.     installs ISR to be executed when interrupt IntNum occurs.
  105.     the address loaded in the interrupt vector is that of the
  106.     start of the procedure ISR, skipping the compiler generated
  107.     entry code.
  108.  
  109.     ISR must be compiled with stack checking disabled ($S-).
  110. *)
  111.  
  112. PROCEDURE ResetVector( IntNum :CARDINAL; ISR :ADDRESS );
  113. (*
  114.     loads the interrupt vector IntNum with the value in ISR
  115. *)
  116.  
  117.  
  118. TYPE
  119.     ErrorProc   = PROCEDURE( CARDINAL, ADDRESS );
  120. (*
  121.     A user error handling procedure is passed, in case of a runtime
  122.     error, the runtime error number and the address of the error
  123.     location.
  124.  
  125.     For a list of current runtime error numbers, please consult the
  126.     system's documentation.
  127.  
  128.     The error address can be related to an address in the MAP file
  129.     produced by DBG2MAP by adjusting the segment part thus:
  130.  
  131.         a.SEG := a.SEG - (PSP + 10H);
  132.  
  133.     If the user error handling procedure returns, default error
  134.     processing will take place and the program is terminated.
  135.  
  136. *)
  137.  
  138. PROCEDURE InstallRTErrorHandler( errorProc :ErrorProc );
  139. (*
  140.     installs errorProc to be invoked if a runtime error is
  141.     detected.
  142.  
  143.     Up to 10 error procedures may be installed, but only the last
  144.     one installed will be invoked in case of a runtime error.
  145. *)
  146.  
  147. PROCEDURE UninstallRTErrorHandler;
  148. (*
  149.     uninstalls the errorProc installed last.
  150. *)
  151.  
  152. PROCEDURE ErrorMessage( msg :ARRAY OF CHAR );
  153. (*
  154.     writes msg to stderr.
  155. *)
  156.  
  157. PROCEDURE ErrorLn;
  158. (*
  159.     writes a newline to stderr.
  160. *)
  161.  
  162. END System.